﻿using M.Warehouse.API.Application.Command.BinLocationsCommand;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.BinLocationsCommandHandlers
{
    /// <summary>
    /// 单独删除库位
    /// </summary>
    public class BinLocationsDeleteCommandHandler : IRequestHandler<BinLocationsDeleteCommand, int>
    {
        private readonly IBinLocationsRepository _repository;
        public BinLocationsDeleteCommandHandler(IBinLocationsRepository repository)
        {
            _repository = repository;
        }
        public async Task<int> Handle(BinLocationsDeleteCommand request, CancellationToken cancellationToken)
        {
            var del = await _repository.GetModelAsync(request.BinLocationId);
            del.IsDeleted = true;
            return await _repository.Update(del);
        }
    }
}
